package com.etiantian.weixin.service.impl;

import com.etiantian.weixin.model.GradeInfo;
import com.etiantian.weixin.model.GradeInfoExample;
import com.etiantian.weixin.dao.GradeInfoMapper;
import com.etiantian.weixin.page.Page;
import com.etiantian.weixin.page.PageHelper;
import com.etiantian.weixin.service.GradeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lujianing on 2014-5-21.
 */
@Service
public class GradeInfoServiceImpl implements GradeInfoService {

    @Autowired
    private GradeInfoMapper gradeInfoMapper;

    @Override
    public List<GradeInfo> listGradeInfoAll() {
        return gradeInfoMapper.selectByExample(new GradeInfoExample());
    }

    @Override
    public List<GradeInfo> listGradeInfo(int page, int page_size) {
        //当第三个参数没有或者为true的时候，进行count查询
        PageHelper.startPage(page, page_size);
        //返回结果默认是List<SysLoginLog>
        //可以通过强制转换为Page<SysLoginLog>,该对象除了包含返回结果外，还包含了分页信息
        Page<GradeInfo> pages = (Page<GradeInfo>) gradeInfoMapper.selectByExample(new GradeInfoExample());
        return pages;
    }
}
